package com.wzk.travelspringboot.controller;

import com.wzk.travelspringboot.dto.NoticeDTO;
import com.wzk.travelspringboot.dto.Result;
import com.wzk.travelspringboot.service.SystemNoticeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

/**
 * @Author: WangZiKang
 * @Date: 2025/1/14 20:05
 */
@Slf4j
@RestController
@RequestMapping("/notice")
@RequiredArgsConstructor
@Validated
public class SystemNoticeController {

    private final SystemNoticeService noticeService;

    @GetMapping
    public Result getAll(){
        return noticeService.queryAll();
    }

    @PostMapping
    public Result addNotice(@RequestBody NoticeDTO dto){
        return noticeService.insertOne(dto);
    }

    @DeleteMapping("/{id}")
    public Result deleteNotice(@PathVariable(name = "id") @NotBlank(message = "id不能为空") String id){
        return noticeService.deleteById(Long.valueOf(id));
    }


}
